package com.dgw.springbootmail.listener;

import org.springframework.stereotype.Component;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import java.util.logging.Logger;


/**
 * @program: springboot-sendmail
 * @description:
 * @author: Mr.Dai
 * @create: 2020-02-29 22:20
 **/
@Component
public class OnlinePersonListener implements HttpSessionListener {

    private static final Logger LOGGER = Logger.getLogger(OnlinePersonListener.class.getName());

    public static  Long onlinePeople= 0L;

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        LOGGER.info("sessionCreated 被创建");
        onlinePeople++;
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        LOGGER.info("sessionCreated 被销毁");
        onlinePeople--;
    }
}
